package com.woniuxy.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.dao.RbacPermDao1;
import com.woniuxy.entity.RbacPerm;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.service.RbacPermService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: wgt
 * Date: 2021/11/28:19:21
 * Description:
 */
@Service
public class RbacPermServiceImpl implements RbacPermService {
    @Autowired
    RbacPermDao1 rbacPermDao1;

    @Override
    public PageInfo<RbacPerm> findAll(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<RbacPerm> all = rbacPermDao1.findAll();
        PageInfo page = new PageInfo(all);
        return page;
    }

    @Override
    public ResponseEntity save(RbacPerm rbacPerm) {
        int perm = rbacPermDao1.save(rbacPerm);
        return new ResponseEntity(200, "新增成功", perm);
    }

    @Override
    public ResponseEntity deleteById(int id) {
        int perm = rbacPermDao1.deleteById(id);
        return new ResponseEntity(200, "删除成功", perm);
    }

    @Override
    public ResponseEntity update(RbacPerm rbacPerm) {
        int perm = rbacPermDao1.update(rbacPerm);
        return new ResponseEntity(200, "修改成功", perm);
    }
}
